package com.oddpointcc.szpt.accounting.security;

import org.apache.commons.lang3.StringUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.oddpointcc.szpt.accounting.utils.WebUtil;

@Service
public class CustomUserDetailsService implements UserDetailsService {

	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		System.out.println(username);
		CustomUserDetails customUserdetails = new CustomUserDetails(1, username, WebUtil.encoderPassword("123456"),
				username, "ROLE_" + StringUtils.upperCase(username), true);
		if (customUserdetails == null) {
			throw new UsernameNotFoundException("该用户不存在");
		}
		return customUserdetails;
	}

}
